package org.example.platform.design.yuanxing;


/**
 * 原型模式
 */
public class YuanXingTest {

    /**
     * 3份简历 第1版
     */
    public static void copy() {
        JianliVo jianliVo = new JianliVo("原型");
        jianliVo.setSex("男");
        jianliVo.setAge("10");
        jianliVo.setWork("工作经历：XXXX");
        System.out.println(jianliVo.toString());


        JianliVo jianliVo1 = new JianliVo("原型");
        jianliVo1.setSex("男");
        jianliVo1.setAge("10");
        jianliVo1.setWork("工作经历：XXXX");
        System.out.println(jianliVo1.toString());


        JianliVo jianliVo2 = new JianliVo("原型");
        jianliVo2.setSex("男");
        jianliVo2.setAge("10");
        jianliVo2.setWork("工作经历：XXXX");
        System.out.println(jianliVo2.toString());
    }


    /**
     * 3份简历 第2版
     */
    public static void copy2() throws CloneNotSupportedException {
        JianliVo jianliVo = new JianliVo("原型");
        jianliVo.setSex("男");
        jianliVo.setAge("10");
        jianliVo.setWork("工作经历：XXXX");
        System.out.println(jianliVo.toString());

        JianliVo jianliVo1 = (JianliVo) jianliVo.clone();
        System.out.println(jianliVo1.toString());

        JianliVo jianliVo2 = (JianliVo) jianliVo.clone();
        System.out.println(jianliVo2.toString());
    }

    /**
     * 3份简历 第3版
     */
    public static void copy3() throws CloneNotSupportedException {
        Company company = new Company();
        company.setCompanyName("百度");
        company.setYear("25");
        JianliVo jianliVo = new JianliVo(company);
        jianliVo.setSex("男");
        jianliVo.setAge("10");
        jianliVo.setWork("工作经历：XXXX");
        jianliVo.setCompany(company);


        System.out.println(jianliVo.toString());

        JianliVo jianliVo1 = (JianliVo) jianliVo.clone();
        Company company2 = new Company();
        company2.setCompanyName("alibaba");
        company2.setYear("27");
        jianliVo.setCompany(company2);
        System.out.println(jianliVo1.toString());

        JianliVo jianliVo2 = (JianliVo) jianliVo.clone();
        System.out.println(jianliVo2.toString());
    }


    public static void main(String[] args) throws CloneNotSupportedException {
        // 第1版
//        copy();
        // 第2版
//        copy2();
        // 第3版
        copy3();
    }
}
